#ifndef __ATTACHED_SIGN_BLOCK_H__
#define __ATTACHED_SIGN_BLOCK_H__

#include "Block.hpp"
#include "IPaintableBlock.hpp"

using namespace PocketSurvival::Engine;

namespace PocketSurvival
{
    // 附着牌子方块基类
    class AttachedSignBlock : public Block, public IPaintableBlock
    {
	public:
		int32_t postedSignBlockIndex;
    public:
		AttachedSignBlock(int32_t postedSign);

        virtual void getDropValues(int32_t oldValue, int32_t newValue, int32_t toolLevel, std::vector<BlockDropValue> &dropValues) override;
        virtual const std::vector<BoundingBox> &getCustomCollisionBoxes(int32_t value) override;

        virtual int32_t getPaintColor(int32_t value) override;
        virtual int32_t paint(int32_t value, int32_t color) override;

		static inline int32_t GetFace(int32_t data);
		static inline int32_t SetFace(int32_t data, int32_t face);
        static inline int32_t GetColor(int32_t data);
        static inline int32_t SetColor(int32_t data, int32_t color);
    };

	inline int32_t AttachedSignBlock::GetFace(int32_t data)
	{
		return data & 3;
	}
	inline int32_t AttachedSignBlock::SetFace(int32_t data, int32_t face)
	{
		return (data & -4) | (face & 3);
	}
    inline int32_t AttachedSignBlock::GetColor(int32_t data)
    {
		if ((data & 4) != 0)
		{
			return (data >> 3) & 0xF;
		}
		return -1;
    }
    inline int32_t AttachedSignBlock::SetColor(int32_t data, int32_t color)
    {
		if (color != -1)
		{
			return (data & -125) | 4 | ((color & 0xF) << 3);
		}
		return data & -125;
    }

} // namespace PocketSurvival


#endif
